Per-vcpu IO evtchn support for VT-i guests (ia64).
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 23 Feb 2006 10:24:37 +0000 (11:24 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 23 Feb 2006 10:24:37 +0000 (11:24 +0100)
Signed-off-by Kevin Tian <kevin.tian@intel.com>
Signed-off-by Xin Li <xin.b.li@intel.com>

xen/arch/ia64/vmx/mmio.c
xen/arch/ia64/vmx/vmx_init.c
xen/arch/ia64/vmx/vmx_support.c
xen/arch/ia64/xen/process.c
xen/include/asm-ia64/vmx.h

index fd06bc14bbc473f09b11a291e4de6dc29acadfe3..e34575404170040a4d8a1d996d744d4a734a1261 100644 (file)
@@ -154,7 +154,7 @@ static void low_mmio_access(VCPU *vcpu, u64 pa, u64 *val, size_t s, int dir)
 
     set_bit(ARCH_VMX_IO_WAIT, &v->arch.arch_vmx.flags);
     p->state = STATE_IOREQ_READY;
-    evtchn_send(iopacket_port(v->domain));
+    evtchn_send(iopacket_port(v));
     vmx_wait_io();
     if(dir==IOREQ_READ){ //read
         *val=p->u.data;
@@ -187,7 +187,7 @@ static void legacy_io_access(VCPU *vcpu, u64 pa, u64 *val, size_t s, int dir)
 
     set_bit(ARCH_VMX_IO_WAIT, &v->arch.arch_vmx.flags);
     p->state = STATE_IOREQ_READY;
-    evtchn_send(iopacket_port(v->domain));
+    evtchn_send(iopacket_port(v));
 
     vmx_wait_io();
     if(dir==IOREQ_READ){ //read
index 16aa37c078f042773f616130fe53ad8754d8cf9c..30661e7591fc0ee3072084c10d6ac17db222aeb3 100644 (file)
@@ -49,6 +49,7 @@
 #include <xen/mm.h>
 #include <public/arch-ia64.h>
 #include <asm/hvm/vioapic.h>
+#include <public/event_channel.h>
 
 /* Global flag to identify whether Intel vmx feature is on */
 u32 vmx_enabled = 0;
@@ -254,9 +255,6 @@ vmx_final_setup_guest(struct vcpu *v)
 {
        vpd_t *vpd;
 
-       /* Allocate resources for vcpu 0 */
-       //memset(&v->arch.arch_vmx, 0, sizeof(struct arch_vmx_struct));
-
        vpd = alloc_vpd();
        ASSERT(vpd);
 
@@ -375,20 +373,15 @@ int vmx_alloc_contig_pages(struct domain *d)
 
 void vmx_setup_platform(struct domain *d, struct vcpu_guest_context *c)
 {
-       shared_iopage_t *sp;
-
        ASSERT(d != dom0); /* only for non-privileged vti domain */
        d->arch.vmx_platform.shared_page_va =
                __va(__gpa_to_mpa(d, IO_PAGE_START));
-       sp = get_sp(d);
-       //memset((char *)sp,0,PAGE_SIZE);
        /* TEMP */
        d->arch.vmx_platform.pib_base = 0xfee00000UL;
 
        /* Only open one port for I/O and interrupt emulation */
        memset(&d->shared_info->evtchn_mask[0], 0xff,
            sizeof(d->shared_info->evtchn_mask));
-       clear_bit(iopacket_port(d), &d->shared_info->evtchn_mask[0]);
 
        /* Initialize the virtual interrupt lines */
        vmx_virq_line_init(d);
@@ -397,4 +390,16 @@ void vmx_setup_platform(struct domain *d, struct vcpu_guest_context *c)
        hvm_vioapic_init(d);
 }
 
+void vmx_do_launch(struct vcpu *v)
+{
+       if (evtchn_bind_vcpu(iopacket_port(v), v->vcpu_id) < 0) {
+           printk("VMX domain bind port %d to vcpu %d failed!\n",
+               iopacket_port(v), v->vcpu_id);
+           domain_crash_synchronous();
+       }
+
+       clear_bit(iopacket_port(v),
+               &v->domain->shared_info->evtchn_mask[0]);
 
+       vmx_load_all_rr(v);
+}
index e6cd6cefb8b38b692cc1c737837a8e1ca4344e6e..7e353be6c68bc16460540a4a6d825bf4c6da9c94 100644 (file)
@@ -38,7 +38,7 @@ void vmx_wait_io(void)
 {
     struct vcpu *v = current;
     struct domain *d = v->domain;
-    int port = iopacket_port(d);
+    int port = iopacket_port(v);
 
     do {
        if (!test_bit(port,
@@ -129,7 +129,7 @@ void vmx_intr_assist(struct vcpu *v)
     struct domain *d = v->domain;
     extern void vmx_vcpu_pend_batch_interrupt(VCPU *vcpu,
                                        unsigned long *pend_irr);
-    int port = iopacket_port(d);
+    int port = iopacket_port(v);
 
     /* I/O emulation is atomic, so it's impossible to see execution flow
      * out of vmx_wait_io, when guest is still waiting for response.
index 249b5e93b634797927a8cef7a1012614587eddc7..0823c9423f5fae89882e7a1a291e78b484a25f59 100644 (file)
@@ -71,7 +71,7 @@ void schedule_tail(struct vcpu *prev)
        context_saved(prev);
 
        if (VMX_DOMAIN(current)) {
-               vmx_load_all_rr(current);
+               vmx_do_launch(current);
        } else {
                load_region_regs(current);
                vcpu_load_kernel_regs(current);
index 910cc9b035d651228f1d627abfb291fa9c6b8a7a..91a0e5ebbe3770ce579db1582ae2f5e4b7c7f72a 100644 (file)
@@ -40,9 +40,9 @@ static inline vcpu_iodata_t *get_vio(struct domain *d, unsigned long cpu)
     return &((shared_iopage_t *)d->arch.vmx_platform.shared_page_va)->vcpu_iodata[cpu];
 }
 
-static inline int iopacket_port(struct domain *d)
+static inline int iopacket_port(struct vcpu *v)
 {
-    return ((shared_iopage_t *)d->arch.vmx_platform.shared_page_va)->sp_global.eport;
+    return get_vio(v->domain, v->vcpu_id)->vp_eport;
 }
 
 static inline shared_iopage_t *get_sp(struct domain *d)